// $Id$
// vim:ft=javascript

ARG_ENABLE("swoole", "SWOOLE support", "no");

if (PHP_SWOOLE != "no") {
	if (CHECK_LIB("ws2_32.lib", "swoole", PHP_SWOOLE)
	&& CHECK_LIB("Iphlpapi.lib", "swoole", PHP_SWOOLE)
	&& CHECK_HEADER_ADD_INCLUDE("winsock.h", "CFLAGS_SWOOLE")) {
		EXTENSION('swoole',
        'src/core/array.c '
        + 'src/core/base.c '
        + 'src/core/channel.c '
        + 'src/core/error.cc '
        + 'src/core/hashmap.c '
        + 'src/core/heap.c '
        + 'src/core/list.c '
        + 'src/core/log.c '
        + 'src/core/rbtree.c '
        + 'src/core/ring_queue.c '
        + 'src/core/socket.c '
        + 'src/core/string.c '
        + 'src/coroutine/base.cc '
        + 'src/coroutine/boost.cc '
        + 'src/coroutine/channel.cc '
        + 'src/coroutine/context.cc '
        + 'src/coroutine/hook.cc '
        + 'src/coroutine/socket.cc '
        + 'src/coroutine/ucontext.cc '
        + 'src/factory/base.c '
        + 'src/factory/process.c '
        + 'src/lock/atomic.c '
        + 'src/lock/cond.c '
        + 'src/lock/file_lock.c '
        + 'src/lock/mutex.c '
        + 'src/lock/rw_lock.c '
        + 'src/lock/semaphore.c '
        + 'src/lock/spin_lock.c '
        + 'src/memory/buffer.c '
        + 'src/memory/fixed_pool.c '
        + 'src/memory/global_memory.c '
        + 'src/memory/malloc.c '
        + 'src/memory/ring_buffer.c '
        + 'src/memory/shared_memory.c '
        + 'src/memory/table.c '
        + 'src/network/client.c '
        + 'src/network/connection.c '
        + 'src/network/dns.c '
        + 'src/network/manager.c '
        + 'src/network/port.c '
        + 'src/network/process_pool.c '
        + 'src/network/reactor_process.c '
        + 'src/network/reactor_thread.c '
        + 'src/network/server.c '
        + 'src/network/stream.c '
        + 'src/network/task_worker.c '
        + 'src/network/thread_pool.c '
        + 'src/network/timer.c '
        + 'src/network/worker.c '
        + 'src/os/base.c '
        + 'src/os/msg_queue.c '
        + 'src/os/sendfile.c '
        + 'src/os/signal.c '
        + 'src/os/timer.c '
        + 'src/os/wait.cc '
        + 'src/pipe/base.c '
        + 'src/pipe/eventfd.c '
        + 'src/pipe/unix_socket.c '
        + 'src/protocol/base.c '
        + 'src/protocol/base64.c '
        + 'src/protocol/http.c '
        + 'src/protocol/http2.c '
        + 'src/protocol/mime_types.cc '
        + 'src/protocol/mqtt.c '
        + 'src/protocol/redis.c '
        + 'src/protocol/sha1.c '
        + 'src/protocol/socks5.c '
        + 'src/protocol/ssl.c '
        + 'src/protocol/websocket.c '
        + 'src/reactor/base.c '
        + 'src/reactor/defer_task.cc '
        + 'src/reactor/epoll.c '
        + 'src/reactor/kqueue.c '
        + 'src/reactor/poll.c '
        + 'src/reactor/select.c '
        + 'swoole.c '
        + 'swoole_async.cc '
        + 'swoole_atomic.c '
        + 'swoole_buffer.c '
        + 'swoole_channel.c '
        + 'swoole_channel_coro.cc '
        + 'swoole_client.c '
        + 'swoole_client_coro.cc '
        + 'swoole_coroutine.cc '
        + 'swoole_coroutine_util.cc '
        + 'swoole_event.c '
        + 'swoole_http_client.c '
        + 'swoole_http_client_coro.cc '
        + 'swoole_http_server.cc '
        + 'swoole_http_v2_client_coro.cc '
        + 'swoole_http_v2_server.cc '
        + 'swoole_lock.c '
        + 'swoole_memory_pool.c '
        + 'swoole_mmap.c '
        + 'swoole_msgqueue.c '
        + 'swoole_mysql.c '
        + 'swoole_mysql_coro.cc '
        + 'swoole_postgresql_coro.cc '
        + 'swoole_process.c '
        + 'swoole_process_pool.c '
        + 'swoole_redis.c '
        + 'swoole_redis_coro.cc '
        + 'swoole_redis_server.cc '
        + 'swoole_ringqueue.c '
        + 'swoole_runtime.cc '
        + 'swoole_serialize.c '
        + 'swoole_server.cc '
        + 'swoole_server_port.cc '
        + 'swoole_socket_coro.cc '
        + 'swoole_table.c '
        + 'swoole_timer.cc '
        + 'swoole_trace.c '
        + 'swoole_websocket_server.cc',
        PHP_SWOOLE_SHARED, "-Iext/swoole/ -Iext/swoole/include /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /w"
        );
		AC_DEFINE('HAVE_SWOOLE', 1);
		PHP_INSTALL_HEADERS("ext/swoole", "php_swoole.h");
	} else {
		WARNING("swoole not enabled; libraries and headers not found");
	}
}
